package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseIdReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseListResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.orderMonitor.OrderMonitorPalletResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.orderMonitor.OrderMonitorReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.orderMonitor.OrderMonitorResVo;
import com.zmj.sy.mom.srv.aps.service.OrderMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Comparator;
import java.util.List;
import java.util.Map;

@Slf4j
@RequiredArgsConstructor
@Api(tags = "订单监控")
@RestController
@RequestMapping("/orderMonitor")
public class OrderMonitorController {

    private final OrderMonitorService orderMonitorService;

    @ApiOperation("订单监控")
    @PostMapping("/getListOld")
    public List<Map<String, Object>> getList(@RequestBody Map<String, Object> mapReq) {
        List<Map<String, Object>> list = orderMonitorService.getList(mapReq);
        list.sort(Comparator.comparing(e -> ((String) e.get("plmid"))));
        return list;
    }

    @ApiOperation("订单监控2.0")
    @PostMapping("/getList")
    public OrderMonitorResVo getListNew(@RequestBody OrderMonitorReqVo reqVo) {
        return orderMonitorService.getListNew(reqVo);
    }

    @ApiOperation("零件所在托盘查询")
    @GetMapping("/getPartPallet")
    public BaseListResVo<OrderMonitorPalletResVo> getPallet(BaseIdReqVo reqVo) {
        return orderMonitorService.getPallet(reqVo);
    }

}
